#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
struct node
{
	int nxt,to;
}e[1000005];
int head[1000005],cnt_edge;
void add_edge(int u,int v)
{
	e[++cnt_edge].to=v;
	e[cnt_edge].nxt=head[u];
	head[u]=cnt_edge;
}
int n,k;
int d[1000005];
int ans;
int dep[1000005],mxdep[1000005];
void dfs(int u,int fa)
{
	mxdep[u]=dep[u];
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		dep[v]=dep[u]+1;
		dfs(v,u);
		mxdep[u]=max(mxdep[u],mxdep[v]);	
	}
	if(u==1) return;
	if(mxdep[u]-dep[u]+(fa!=1)>=k) ++ans,mxdep[u]=0;
}
int main()
{
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	n=read(),k=read();
	for(int i=1;i<=n;i++) d[i]=read();
	if(d[1]!=1) ++ans;
	for(int i=2;i<=n;i++) add_edge(d[i],i);
	dfs(1,0);
	write(ans);
	return 0;
}
